#include <QThread>

#include "testimagedownloader.h"
#include "../imagedownloader.h"
#include "../utils.h"

static const QString ImageUrl = "http://h.hiphotos.baidu.com/baike/w%3D268/sign=2abc36dc942397ddd6799f026183b216/77c6a7efce1b9d16b27e955af6deb48f8c54644b.jpg";

testImageDownloader::testImageDownloader()
{
//    QString saveDir = Jcr::Utils::makeDirectory("test", "test");
    Jcr::ImageDownloader* imageDownloader = new Jcr::ImageDownloader(ImageUrl, "F:/", nullptr);
    imageDownloader->setSaveName("keji");

    QThread* thread = new QThread();
    imageDownloader->moveToThread(thread);

    connect(thread, SIGNAL(started()), imageDownloader, SLOT(run()));
    connect(imageDownloader, SIGNAL(finished()), thread, SLOT(terminate()));
    connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
    connect(thread, SIGNAL(finished()), imageDownloader, SLOT(deleteLater()));
    thread->start();
}

